import { defineStore } from 'pinia'
import { ref } from "vue";

export const useCounterStore = defineStore('counter', {
  state: () => {
    return { count: 0 }
  },
  // 也可以定义为
  // state: () => ({ count: 0 })
  getters:{
    doubleCount:(state)=>state.count*2,
    xixiCount():number{
      return this.doubleCount + 1
    },
  },
  actions: {
    increment() {
      this.count++
    },
  },
})
export const useCounter2Store = defineStore('counter2',()=>{
  const count = ref(0)
  function increment() {
    count.value ++
  }
  return {count,increment}
})